package com.zp.crm.Controller.MarDevelopController;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.google.gson.Gson;
import com.zp.crm.service.MarDevelopService.MarDevelopService;

@Controller
@RequestMapping("/marDevelop")
public class MarDevelopController {
	
	@Resource
	public MarDevelopService mardevelopService;
	
	@RequestMapping(value="/select",method=RequestMethod.POST)
	public void SelectCreate(HttpServletRequest request,HttpServletResponse response,Model model){
		response.setContentType("text/html;charset=utf-8");
		
		String code=request.getParameter("code");
		
		Map<String, Object> map=mardevelopService.select(code);
		
		String a=(String) map.get("message");
		
		try {
			PrintWriter out = response.getWriter();
			out.println(a);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
	}
	@RequestMapping(value="/insert",method=RequestMethod.POST)
	public void MarDevelopInsert(HttpServletRequest request,HttpServletResponse response,Model model){
			
		response.setContentType("text/html;charset=utf-8");
		
		String code=request.getParameter("code");
		
		String obj=request.getParameter("obj");
		
		Map<String, Object> map=mardevelopService.insert(code,obj);
		
		try {
			PrintWriter out = response.getWriter();
			String json = new Gson().toJson(map);
			out.println(json);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}
	
}
